package com.rockcent.mall.lib.repository;

import com.rockcent.mall.lib.domain.MarketMerchantCooperation;
import com.rockcent.mall.lib.domain.enumclass.MarketMerchantCooperationStatus;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

/**
 * Created by oyhk on 14-6-22.
 *
 */
@Repository
public interface MarketMerchantCooperationRepository extends JpaRepository<MarketMerchantCooperation, Long>, JpaSpecificationExecutor, MarketMerchantCooperationRepositoryCustom {


    /**
     * 供应商 合作数
     * @param formMerchantId
     * @param status
     * @return
     */
    Long countByDistributorMerchantIdAndStatus(Long formMerchantId, MarketMerchantCooperationStatus status);
    /**
     * 分销商 合作数
     * @param formMerchantId
     * @param status
     * @return
     */
    Long countBySupplierMerchantIdAndStatus(Long formMerchantId, MarketMerchantCooperationStatus status);


    MarketMerchantCooperation findBySupplierMerchantIdAndDistributorMerchantIdAndStatusNot(Long supplierMerchantId, Long distributorMerchantId, MarketMerchantCooperationStatus status);
}
